package cn.myeasyai.config;

import cn.myeasyai.face.Face;
import cn.myeasyai.face.FaceFactory;
import cn.myeasyai.util.IdWorker;
import com.obs.services.ObsClient;
import io.milvus.client.MilvusServiceClient;
import io.milvus.param.ConnectParam;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author fushoujiang
 */
@Configuration
public class SpringConfig {
    @Bean
    public ObsClient obsClient(FileConfig FileConfig){
        final FileConfig.Obs config = FileConfig.getObs();
        return  new ObsClient(config.getAccessKeyId(), config.getSecretAccessKeyId(),config.getEndPoint());
    }

    @Bean
    public MilvusServiceClient milvusServiceClient(MilvusConfig milvusConfig){
        return new MilvusServiceClient (ConnectParam.newBuilder().withUri(milvusConfig.getUri()).withToken(milvusConfig.getToken()).build());
    }
    @Bean
    public IdWorker idWorker(IdWorkConfig workConfig){
        return new IdWorker(workConfig.getWorkerId(),workConfig.getDateCenterId());
    }
    @Bean
    public Face face( ){
        return FaceFactory.getFace();
    }
}
